<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		.box{
			width:300px;
			height:300px;
			background:gold;
		}
	</style>
	<script type="text/javascript">
		
		window.onload = function(){

			var oBtn = document.getElementById('btn');
			var oDiv = document.getElementById('box');

			//alert(oDiv.style.display); 弹成 空 的值

			oBtn.onclick = function(){

				if(oDiv.style.display=='block' || oDiv.style.display==''){
					oDiv.style.display = 'none';
				}
				else
				{
					oDiv.style.display = 'block';
				}
			}

		}




	</script>
</head>
<body>
	<input type="button" name="" value="切换" id="btn">
	<div class="box" id="box"></div>
</body>
</html>